package com.whs.demo.application;

import com.badlogic.gdx.backends.jglfw.JglfwApplication;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import com.badlogic.gdx.utils.viewport.Viewport;
import com.whs.demo.Demo;
import com.whs.demo.assets.Assets;
import com.whs.demo.ui.ProgressActor;


/**
 * 
 * @Description:   
 * @author whs   
 * @date 2015-11-24 下午3:02:17 
 * @version V1.0 
 *
 */
public class MainDemo   extends Demo {

    private Stage stage;
    private OrthographicCamera camera;
    private Viewport viewport;
    

    @Override
    public void create() {
        super.create();
        Assets.init();
        Assets.loadAll();
        Assets.finishLoading();
        Assets.initTestAtlas();
        stage = new Stage();
        camera = new OrthographicCamera(WIDTH, HEIGHT);
        camera.position.set(WIDTH / 2, HEIGHT / 2, 0);
        viewport = new ScreenViewport(camera);
        viewport.setCamera(camera);
        stage.setViewport(viewport);
        camera.update();
        
        // 进度条
        ProgressActor progress = new ProgressActor();
        progress.setPosition(100, 700);
        stage.addActor(progress);
    }

    @Override
    public void render() {

        super.render();
        stage.act();
        stage.draw();
    }

    @Override
    public void dispose() {
        super.dispose();
        stage.dispose();
        Assets.dispose();
    }

    public static void main(String[] args) {
        new JglfwApplication(new MainDemo(), "Demo - By WHS", WIDTH , HEIGHT);
    }

}
